package com.etc.entity;

import java.io.Serializable;
import java.util.UUID;

public class Role implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -6592853538853992566L;
	private String roleId;   //角色编号
	private String nickname;  //角色昵称
	private int heal;         //角色的生命值
	private int image;       //角色的魔法值
	private int attack;      //角色的攻击力
	private int critical;    //角色的暴击
	private int defense;     //角色的防御力
	private int speed;       //角色的速度
	private RoleEquipment roleEquip;  //角色的装备
	private Career career;     //角色的职业
	private String userId;  //所属账号

	//开始游戏
	public void startGame() {
		
	}
	//选择敌人
	public void chooseEnemy() {
		
	}
	//减少血量
	public void reduceHeal(int damage) {
		if(heal - damage >0) {
			heal -= damage;
		}else {
			heal = 0;
		}
	}
	
	public Role(String roleId, String nickname, int heal, int image, int attack, int critical, int defense, int speed,
			RoleEquipment roleEquip, Career career, String userId) {
		super();
		this.roleId = roleId;
		this.nickname = nickname;
		this.heal = heal;
		this.image = image;
		this.attack = attack;
		this.critical = critical;
		this.defense = defense;
		this.speed = speed;
		this.roleEquip = roleEquip;
		this.career = career;
		this.userId = userId;
	}
	public Role(String nickname, int heal, int image, int attack, int critical, int defense, int speed,
			RoleEquipment roleEquip, Career career, String userId) {
		super();
		this.roleId = UUID.randomUUID().toString().substring(0, 8);
		this.nickname = nickname;
		this.heal = heal;
		this.image = image;
		this.attack = attack;
		this.critical = critical;
		this.defense = defense;
		this.speed = speed;
		this.roleEquip = roleEquip;
		this.career = career;
		this.userId = userId;
	}
	public Role() {
		super();
	}
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public String getRoleId() {
		return roleId;
	}
	public void setRoleId(String roleId) {
		this.roleId = roleId;
	}
	public String getNickname() {
		return nickname;
	}
	public void setNickname(String nickname) {
		this.nickname = nickname;
	}
	public int getHeal() {
		return heal;
	}
	public void setHeal(int heal) {
		this.heal = heal;
	}
	public int getImage() {
		return image;
	}
	public void setImage(int image) {
		this.image = image;
	}
	public int getAttack() {
		return attack;
	}
	public void setAttack(int attack) {
		this.attack = attack;
	}
	public int getCritical() {
		return critical;
	}
	public void setCritical(int critical) {
		this.critical = critical;
	}
	public int getDefense() {
		return defense;
	}
	public void setDefense(int defense) {
		this.defense = defense;
	}
	public int getSpeed() {
		return speed;
	}
	public void setSpeed(int speed) {
		this.speed = speed;
	}
	public RoleEquipment getRoleEquip() {
		return roleEquip;
	}
	public void setRoleEquip(RoleEquipment roleEquip) {
		this.roleEquip = roleEquip;
	}
	public Career getCareer() {
		return career;
	}
	public void setCareer(Career career) {
		this.career = career;
	}
	@Override
	public String toString() {
		return "Role [roleId=" + roleId + ", nickname=" + nickname + ", heal=" + heal + ", image=" + image + ", attack="
				+ attack + ", critical=" + critical + ", defense=" + defense + ", speed=" + speed + ", roleEquip="
				+ roleEquip + ", career=" + career + "]";
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + attack;
		result = prime * result + ((career == null) ? 0 : career.hashCode());
		result = prime * result + critical;
		result = prime * result + defense;
		result = prime * result + heal;
		result = prime * result + image;
		result = prime * result + ((nickname == null) ? 0 : nickname.hashCode());
		result = prime * result + ((roleEquip == null) ? 0 : roleEquip.hashCode());
		result = prime * result + ((roleId == null) ? 0 : roleId.hashCode());
		result = prime * result + speed;
		result = prime * result + ((userId == null) ? 0 : userId.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Role other = (Role) obj;
		if (attack != other.attack)
			return false;
		if (career == null) {
			if (other.career != null)
				return false;
		} else if (!career.equals(other.career))
			return false;
		if (critical != other.critical)
			return false;
		if (defense != other.defense)
			return false;
		if (heal != other.heal)
			return false;
		if (image != other.image)
			return false;
		if (nickname == null) {
			if (other.nickname != null)
				return false;
		} else if (!nickname.equals(other.nickname))
			return false;
		if (roleEquip == null) {
			if (other.roleEquip != null)
				return false;
		} else if (!roleEquip.equals(other.roleEquip))
			return false;
		if (roleId == null) {
			if (other.roleId != null)
				return false;
		} else if (!roleId.equals(other.roleId))
			return false;
		if (speed != other.speed)
			return false;
		if (userId == null) {
			if (other.userId != null)
				return false;
		} else if (!userId.equals(other.userId))
			return false;
		return true;
	}
	
	
}
